package com.changil.nowonchangil.rest;

import java.sql.SQLException;
import java.util.ArrayList;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.changil.nowonchangil.controller.ServiceController;
import com.changil.nowonchangil.dto.BibleWord;
import com.changil.nowonchangil.dto.BibleWordList;
import com.changil.nowonchangil.dto.GracefulWord;
import com.changil.nowonchangil.dto.Word;

@Path("/words")
public class RestWords {
	private ServiceController controller = new ServiceController();

	public void SetScoreService(ServiceController controller) {
		this.controller = controller;
	}

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("this_week_bible_words")
	public BibleWordList getThisWeekBibleWords(
			@QueryParam("date") String date) {
		BibleWordList result = new BibleWordList();
		ArrayList<BibleWord> list = null;
		list = controller.getThisWeekBibleWords(date);
		result.size = list.size();
		result.list = list;
		return result;
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("last_week_words")
	public Word getLastWeekWord(
			@QueryParam("date") String date) {
		Word result = new Word();
		result = controller.getLastWeekWord(date);
		return result;
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("graceful_words")
	public GracefulWord getGracefulWord(
			@QueryParam("date") String date) {
		GracefulWord result = new GracefulWord();
		result = controller.getGracefulWord(date);
		return result;
	}
	
}
